from django.contrib import admin
from goods.models import *
from django.core.cache import cache
# Register your models here.
class BaseModelAdmin(admin.ModelAdmin):
    def save_model(self,request,obj,form,change):
        super().save_model(request,obj,form,change)
        from celery_tasks.task import generate_static_index
        generate_static_index.delay()
        cache.delete('indexpage')
    def delete_model(self,request,obj,form,change):
        super().delete_model(request,obj,form,change)
        from celery_tasks.task import generate_static_index
        generate_static_index.delay()
        cache.delete('indexpage')

admin.site.register(GoodsType,BaseModelAdmin)
admin.site.register(IndexGoodsBanner,BaseModelAdmin)
admin.site.register(IndexTypeGoodsBanner,BaseModelAdmin)
admin.site.register(GoodsSKU,BaseModelAdmin)
admin.site.register(Goods,BaseModelAdmin)
admin.site.register(IndexPromotionBanner,BaseModelAdmin)

